Conversation
| $this->handle = (is_resource($file) ? $file : @ fopen($file, 'rb')); | ||
|
|
||
| if ($this->handle === false) { | ||
| throw new \InvalidArgumentException('Cannot open file for reading: ' . $file); |
There was a problem hiding this comment.
What do you mean about this comment?
There was a problem hiding this comment.
I don't like the null coalesce operator here, as it also allows for undefined variable without notice. This operator is equivalent to isset($values) ? $values : [], not strictly equivalent to the original code.
There was a problem hiding this comment.
This condition is not related to the null coalesce operator.
I think this change is proper approach.
src/ObjectArrayStorage.php
Outdated
| $values = $this->storage->get($object); | ||
|
|
||
| return ($values === null) ? [] : $values; | ||
| return $values ?? []; |
There was a problem hiding this comment.
I don't like the null coalesce operator here, as it also allows for undefined variable without notice. This operator is equivalent to isset($values) ? $values : [], not strictly equivalent to the original code.
| } | ||
|
|
||
| throw new \UnexpectedValueException('Object not found.'); | ||
| return $this->data[$hash]; |
There was a problem hiding this comment.
This approach is about error exception first.
It's about change the order of conditions.
There was a problem hiding this comment.
I got that, but what's the point? Please don't spent time on nitpick like this :)
There was a problem hiding this comment.
Ok. I will not spend time about this change.
src/ObjectStorage.php
Outdated
| } | ||
|
|
||
| return null; | ||
| return $this->data[$hash] ?? null; |
There was a problem hiding this comment.
You can keep this change alone.
There was a problem hiding this comment.
How about reverting this due to your previous comment.
There was a problem hiding this comment.
This is an isset($x) ? $x : null, so conceptually equivalent to $x ?? null. I can accept this change.
Changed log
?:operator to do that.??syntax to reduce conditions.Exceptionfirst to enhance condition logic.